﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using ClassLibraryDatabase;
using ClassLibraryBaseClass;

namespace DataBaseHelper
{
    class Program
    {
		static void Main()
		{
			try
			{
				//Test1.Test();
				//Test2.Test();
				//Test3.Test();
				//Test5.Test();
				//Test6.Test();
				//Test7.Test();
				Test1.Test();
				ClassLibraryBaseClass.Test1.Test();
				ClassLibraryBaseClass.Test2.Test();
				ClassLibraryBaseClass.Test3.Test();
				ClassLibraryBaseClass.Test5.Test();
				ClassLibraryBaseClass.Test6.Test();
				ClassLibraryBaseClass.Test7.Test();
				////DataTable table = DataBaseClass.selectData(null, null, "Movies", "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Users\\ibm\\Desktop\\MOVIE.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
				//Movie movie = Movie.GetMovieByID("1");
				//movie = new Movie(1, "123asdaf21312", "12", "23", DateTime.Now, 292, "1ads", "1ads", "1ads", 5, null, null);
				////movie.AddThisItemToDatabase();
				//movie = Movie.GetMovieByDataTable(Movie.GetMovieByName("画皮").Rows[0]);
				//movie = Movie.GetMovieByID("2");
				//movie.Grade = 7.0M;
				//movie.Update();
				//movie = Movie.GetMovieByID("1");
				//DataTable table = Movie.GetMovieByID("1").GetTheatreByMovie();
				//string s = table.Rows[0]["Name"].ToString();
				//s = table.Rows[1]["Address"].ToString();
				//table = movie.GetCommentByMovie();
				//s = table.Rows[0]["Detail"].ToString();
				//table = movie.GetSessionByMovie();
				//s = table.Rows[0]["Time"].ToString();
				//Favorites f = new Favorites(1, 6);
				//f.AddFavoriteMovie();
				//f = new Favorites(1, 7);
				//f.AddFavoriteMovie();
				//Favorites.AddFavoriteMovie(1, 8);
				//table = DataBaseClass.selectData("SELECT *  FROM MovieUser WHERE ID=1", Movie.GetConStr());
				//User user = User.LogIn("Administrator", "123456");
				//user.LogOut();
				//movie = new Movie(1, "123asdaf21312", "12", "23", DateTime.Now, 292, "1ads", "1ads", "1ads", 5, null, null);
				//movie.AddThisItemToDatabase();
				//int nID = movie.ID;
				//DataBaseClass.insertData("INSERT Session (MovieID , TheaterID , Time , NTSC , Price , Hall) VALUES (" + nID + "," + 1 + ",'" + DateTime.Today.ToString() + "','3D',85.0000,'3')", Movie.GetConStr());
				//movie.DeleteItselfFromDatabase();
			}
			finally
			{
			}
			//movie = 
		}
        static void Main1()
        {
            // Create a new SqlConnectionStringBuilder and
            // initialize it with a few name/value pairs.
            SqlConnectionStringBuilder builder =
                new SqlConnectionStringBuilder(GetConnectionString());

            // The input connection string used the 
            // Server key, but the new connection string uses
            // the well-known Data Source key instead.
            Console.WriteLine(builder.ConnectionString);

            // Pass the SqlConnectionStringBuilder an existing 
            // connection string, and you can retrieve and
            // modify any of the elements.
            builder.ConnectionString = "server=(local);user id=ab;" +
                "password= a!Pass113;initial catalog=AdventureWorks";

            // Now that the connection string has been parsed,
            // you can work with individual items.
            Console.WriteLine(builder.Password);
            builder.Password = "new@1Password";
            builder.AsynchronousProcessing = true;

            // You can refer to connection keys using strings, 
            // as well. When you use this technique (the default
            // Item property in Visual Basic, or the indexer in C#),
            // you can specify any synonym for the connection string key
            // name.
            builder["Server"] = ".";
            builder["Connect Timeout"] = 1000;
            builder["Trusted_Connection"] = true;
            Console.WriteLine(builder.ConnectionString);

            Console.WriteLine("Press Enter to finish.");
            Console.ReadLine();
        }

        private static string GetConnectionString()
        {
            // To avoid storing the connection string in your code,
            // you can retrieve it from a configuration file. 
            return "Server=(local);Integrated Security=SSPI;" +
                "Initial Catalog=AdventureWorks";
        }
    }
}
